Skip to main content

All Questions

0votes
1answer
7kviews

How to count empty line using grep

I have a text file. Some lines contain text while others do not (just empty line without any spaces or characters: 123 // comment 45 As you can see, there is a line above //comment. If I want to ...
user avatar
1vote
2answers
2kviews

How to select specific columns from a file with a string separator

I have a file with columns separated by a string. For example: one<xx>two<xx>three<xx>four<xx>five<xx>six one11<xx>two11<xx>three11<xx>four11<xx>...
user avatar
3votes
4answers
6kviews

How to remove trailing forward slash

For each line in my file, if the line ends with / I want to remove it. How to do this? My attempt: sed -e "s/$\/$//" myfile.txt > myfile_noslash.txt Did not work.
user9371654's user avatar
-1votes
1answer
342views

Search for a string in lots files in a directory, if found, save the file name and line

I have several files, with different names. no specific format for them. But all are .txt. For example: example.txt flower.txt abc.com.txt They are in the same directory. I want to search for a ...
user9371654's user avatar
0votes
2answers
377views

How to extract string between the first occurrence of : and a colon

I have a long file that I need to reprocess for entering it into database. The file's data are in this format: Error for: 111.222.55.1,[ZXX: Error message] some text (_xxx.c:833) Error for: 198.243....
user9371654's user avatar
0votes
3answers
478views

count country code in a file and save a file command or bash script

Situation: I would like to write bash script or a command which will count only country code in /var/log/mywebsite.log how many of them then save a file. I would like this script to check Linux time ...
danone's user avatar
2votes
5answers
82kviews

Find text in a file and copy it to another file

Is there any command in Linux to find text in a file and if found then copy it in another file? Using sed -i we can find text but how to copy whole line in another file?
jordan's user avatar

close